package com.xindong.paking.controller;

import com.xindong.paking.entity.vo.LoginParams;
import com.xindong.paking.service.LoginService;
import com.xindong.paking.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "登陆模块")
@RestController
@RequestMapping("/login")
public class LoginController {

    @Autowired
    private LoginService loginService;

    @ApiOperation("登陆")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "username", value = "用户名",required = true),
            @ApiImplicitParam(name = "password", value = "密码",required = true)
    })
    //@GetMapping
    //public Result login(@RequestParam("username") String username, @RequestParam("password") String password) {
    //    return loginService.login(username, password);
    //}
    @PostMapping
    public Result login(@RequestBody LoginParams params) {
        return loginService.login(params.getUsername(), params.getPassword());
    }

}
